home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
uucp
/
AM114src.lha
/
client.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-29
|
6KB
|
322 lines
/*
*
* AM --- AmigaMail
* (C) 1991, 1992 by Christian Riede
*
* AM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY. No author or distributor accepts responsibility to anyone
* for the consequences of using it or for whether it serves any
* particular purpose or works at all, unless he says so in writing.
* Refer to the GNU General Public License, Version 1, for full details.
*
* Everyone is granted permission to copy, modify and redistribute AM,
* but only under the conditions described in the GNU General Public
* License, Version 1. A copy of this license is supposed to have been
* given to you along with AM so you can know your rights and responsi-
* bilities. It should be in a file named COPYING. Among other things,
* the copyright notice and this notice must be preserved on all copies.
*
*
*
*/
#include "am.h"
struct MsgPort *ServerPort;
struct AMMessage *AskServer(struct AMMessage *Msg)
{
struct AMMessage *Return;
struct MsgPort *ClientPort;
Return = 0;
/* server running ?*/
if (ServerPort)
{
/* to be reentrant we must create our own port */
if (!(ClientPort = CreatePort(0,0)))
return(0);
Msg->AMMsg.mn_ReplyPort = ClientPort;
/* give him the message */
PutMsg(ServerPort,(struct Message *)Msg);
/* receive reply */
/* since all requests are done syncronously */
/* the first message must be the reply to our request */
if (!(Return = (struct AMMessage *)GetMsg(ClientPort)))
{
/* wait for reply */
WaitPort(ClientPort);
/* return the replied message */
Return = (struct AMMessage *)GetMsg(ClientPort);
}
DeletePort(ClientPort);
}
return(Return);
}
int KillServer(void)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_DIE;
AskServer(Msg); /* don't care for results */
ret = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}
int LockContents(void)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_LOCKCONTENTS;
Msg->Username = Username;
AskServer(Msg); /* don't care for results */
ret = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}
void UnLockContents(void)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return;
Msg->Action = ACT_UNLOCKCONTENTS;
Msg->Username = Username;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
}
int GetContents(struct List *Mailbox)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_GETCONTENTS;
Msg->Username = Username;
Msg->Mailbox = Mailbox;
AskServer(Msg); /* don't care for results */
ret = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}
struct Mail *AddItem(ULONG num)
{
struct AMMessage *Msg;
struct Mail *New;
if (!(Msg = AllocAMMsg()))
return(0);
Msg->Action = ACT_ADD_ITEM;
Msg->Username = Username;
Msg->Number = num;
AskServer(Msg); /* don't care for results */
New = Msg->NewMail;
FreeMem(Msg,sizeof(struct AMMessage));
return(New);
}
void MarkRead(ULONG num)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return;
Msg->Action = ACT_MARK_READ;
Msg->Username = Username;
Msg->Number = num;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
}
void MarkUnread(ULONG num)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return;
Msg->Action = ACT_MARK_UNREAD;
Msg->Username = Username;
Msg->Number = num;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
}
void MarkOld(ULONG num)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return;
Msg->Action = ACT_MARK_OLD;
Msg->Username = Username;
Msg->Number = num;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
}
void DeleteItem(ULONG num)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return;
Msg->Action = ACT_DELETE_ITEM;
Msg->Username = Username;
Msg->Number = num;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
}
ULONG NewSeq(void)
{
struct AMMessage *Msg;
ULONG seq;
if (!(Msg = AllocAMMsg()))
return(0);
Msg->Action = ACT_NEW_SEQ;
Msg->Username = Username;
AskServer(Msg); /* don't care for results */
seq = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(seq);
}
int NotifyOn(struct MsgPort *NotifyPort)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_NOTIFY_ON;
Msg->Username = Username;
Msg->NotifyPort = NotifyPort;
AskServer(Msg); /* don't care for results */
ret = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}
int NotifyOff(struct MsgPort *NotifyPort)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_NOTIFY_OFF;
Msg->Username = Username;
Msg->NotifyPort = NotifyPort;
AskServer(Msg); /* don't care for results */
ret = Msg->Number;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}
char *NewMsgId(char *s)
{
struct AMMessage *Msg;
if (!(Msg = AllocAMMsg()))
return(0);
Msg->Action = ACT_NEW_MSGID;
Msg->MsgId = s;
AskServer(Msg); /* don't care for results */
FreeMem(Msg,sizeof(struct AMMessage));
return(s);
}
int CmpVersion(void)
{
struct AMMessage *Msg;
int ret;
if (!(Msg = AllocAMMsg()))
return(FALSE);
Msg->Action = ACT_VERSION;
AskServer(Msg); /* don't care for results */
if (Msg->MsgId) /* very old servers (before 1.7) do not respond to ACT_VERSION */
ret = !strcmp(Msg->MsgId,AMIGAMAIL_VERSION);
else
ret = FALSE;
FreeMem(Msg,sizeof(struct AMMessage));
return(ret);
}